package io.renren.modules.personnel.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.personnel.entity.FirstTryListEntity;
import io.renren.modules.personnel.service.FirstTryListService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 初试通过名单
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2022-01-02 18:21:01
 */
@RestController
@RequestMapping("personnel/firsttrylist")
public class FirstTryListController {
    @Autowired
    private FirstTryListService firstTryListService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("personnel:firsttrylist:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = firstTryListService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{firstTryId}")
    @RequiresPermissions("personnel:firsttrylist:info")
    public R info(@PathVariable("firstTryId") Long firstTryId){
        FirstTryListEntity firstTryList = firstTryListService.getById(firstTryId);

        return R.ok().put("firstTryList", firstTryList);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("personnel:firsttrylist:save")
    public R save(@RequestBody FirstTryListEntity firstTryList){
        firstTryListService.save(firstTryList);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("personnel:firsttrylist:update")
    public R update(@RequestBody FirstTryListEntity firstTryList){
        ValidatorUtils.validateEntity(firstTryList);
        firstTryListService.updateById(firstTryList);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("personnel:firsttrylist:delete")
    public R delete(@RequestBody Long[] firstTryIds){
        firstTryListService.removeByIds(Arrays.asList(firstTryIds));

        return R.ok();
    }

}
